<?php
class PersonalministrieslessonsController extends AppController {

    public $helpers = array('Html', 'Form');
    public $components = array('Session');

    public function index() {
        $pageTitle ="Worldwide Seventhday-Adventisth Church - Kwabrafoso: Personal Ministries Lesson Study";
        $in_record_data = $this->Personalministrieslesson->find('all');
        $this->set(compact('in_record_data','pageTitle'));
    }
  
    public function add(){
    $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Enter Personal Ministries Lesson Study";
     if($_POST){
       // pr($_POST);
        $data['Personalministrieslesson'] = array(
            'lyear' => $_POST['lyear'],
            'qtr' => $_POST['qtr'],
            'date' => $_POST['date'],
            'topic' => $_POST['topic'],
            'ltxt' => $_POST['ltxt'],
            'leader' => $_POST['leader']
        );

        if(!$this->Personalministrieslesson->save($data)){
            $this->Session->setFlash('Error Saving Personal Ministries Lesson Study');
        }else{
             $this->Session->setFlash('Personal Ministries Lesson Study Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','errorMsg'));
}
    
    // A functin to delete Personalministrieslesson
    public function delete($id = null)
    {
       if (!$id) 
       {
        $this->Session->setFlash('Invalid id for Personal Ministries Lesson Study');
        $this->redirect(array('action' => 'index'));
    }
    if ($this->Personalministrieslesson->delete($id)) 
    {
        $this->Session->setFlash('Personal Ministries Lesson Study Deleted Please');
    } else 
    {
        $this->Session->setFlash(__('Personal Ministries Lesson Study Not Deleted', true));
    }
    $this->redirect(array('action' => 'index'));
}

    // A functin to edit Personalministrieslesson
    function edit($id = null){
    $record_id = $id;
    $conditions = array('Personalministrieslesson.id' => $record_id);
    $record = $this->Personalministrieslesson->find('first', array('conditions' => $conditions, 'recursive' => 1));
   // pr($record);
            
     $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Edit Personal Ministries Lesson Study";
     if($_POST){
        //pr($_POST);
       $data['Personalministrieslesson'] = array(
            'lyear' => $_POST['lyear'],
            'qtr' => $_POST['qtr'],
            'date' => $_POST['date'],
            'topic' => $_POST['topic'],
            'ltxt' => $_POST['ltxt'],
            'leader' => $_POST['leader']
        );

        if(!$this->Personalministrieslesson->save($data)){
            $this->Session->setFlash('Error Saving Data');
        }else{
             $this->Session->setFlash('Data Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','record'));
}

     // A functin to view Records
    public function view($id) {
    if (!$id) {
        throw new NotFoundException(__('Invalid Record'));
    }

    $personalministrieslesson = $this->Personalministrieslesson->findById($id);
    if (!$personalministrieslesson) {
        throw new NotFoundException(__('Invalid Record'));
    }
    $this->set('Personalministrieslesson', $personalministrieslesson);
}

function report($id = null){
    $record_id = $id;
    $conditions = array('Personalministrieslesson.id' => $record_id);
    $record = $this->Personalministrieslesson->find('first', array('conditions' => $conditions, 'recursive' => 1));
//    pr($record);

}

}
?>